const  express= require("express");
const  app=express();

const bodyParser = require('body-parser')
app.use(bodyParser.urlencoded({ extended: false }))

app.use(express.static("./views"));
/* get传参  使用req.query获取 */
app.get("/user",(req,res)=>{
    console.log(req.query);
    res.send("ok");
});

/* get传参  使用req.params */
app.get("/aa/:id/:name",(req,res)=>{
    console.log(req.params);
    res.send("ok");
});

/*  post传参  使用req.body   但是需要引入 body-parser*/ 
app.post("/user",(req,res)=>{
    console.log(req.body);
    res.send("ok");
});


app.listen(2100,()=>{
    console.log('server running at http://127.0.0.1:2100') 
});
